/*
 * lcd_init.h
 *
 *  Created on: 27.11.2011
 *      Author: Roma Jam
 */

#include "stm32f10x_gpio.h"

#ifndef LCD_INIT_H_
#define LCD_INIT_H_

#define STEER                   // If device is Steer
//#define STM32                   // If device is STM32VLDiscovery

#ifdef STEER
#define LCD_GPIO_PORT           GPIOB
#define LCD_CLK                 RCC_APB2Periph_GPIOB

#define LCD_BCKLT               GPIO_Pin_0
#define LCD_SCLK                GPIO_Pin_12
#define LCD_SDA                 GPIO_Pin_10
#define LCD_XRES                GPIO_Pin_5
#define LCD_XCS                 GPIO_Pin_2
#endif /* STEER */

#ifdef STM32
#define LCD_GPIO_PORT           GPIOA
#define LCD_CLK                 RCC_APB2Periph_GPIOA

#define LCD_BCKLT               GPIO_Pin_1
#define LCD_SCLK                GPIO_Pin_2
#define LCD_SDA                 GPIO_Pin_3
#define LCD_XRES                GPIO_Pin_5
#define LCD_XCS                 GPIO_Pin_4
#endif /* STM32 */

#define LCD_SCLK_HI()           GPIO_SetBits(LCD_GPIO_PORT, LCD_SCLK)
#define LCD_SCLK_LO()           GPIO_ResetBits(LCD_GPIO_PORT, LCD_SCLK)
#define LCD_SDA_HI()            GPIO_SetBits(LCD_GPIO_PORT, LCD_SDA)
#define LCD_SDA_LO()            GPIO_ResetBits(LCD_GPIO_PORT, LCD_SDA)
#define LCD_XRES_HI()           GPIO_SetBits(LCD_GPIO_PORT, LCD_XRES)
#define LCD_XRES_LO()           GPIO_ResetBits(LCD_GPIO_PORT, LCD_XRES)
#define LCD_XCS_HI()            GPIO_SetBits(LCD_GPIO_PORT, LCD_XCS)
#define LCD_XCS_LO()            GPIO_ResetBits(LCD_GPIO_PORT, LCD_XCS)

#define Lcd_Backlight_On()      GPIO_SetBits(LCD_GPIO_PORT, LCD_BCKLT)
#define Lcd_Backlight_Off()     GPIO_ResetBits(LCD_GPIO_PORT, LCD_BCKLT)

class lcd_t {
private:

public:
    void Init(void);
    void PrintMenu(uint8_t Ax_var, uint8_t Ay_var, uint32_t AOn, uint32_t AOff);
    void Reset(void);
    void WriteCmd(uint8_t AByte);
    void WriteData(uint8_t AByte);
    void Clear(void);
    void Clear_zone(const uint8_t x, const uint8_t y, uint8_t size_of_zone);
    void DrawChar(uint8_t AChar, bool AInvert);
    void GotoXY(uint8_t x, uint8_t y);
    void GotoXYstr(uint8_t x, uint8_t y);
    void Show_Point (const uint8_t x, const uint8_t y, const uint8_t w);
    void Clear_Point (const uint8_t x, const uint8_t y);
    void Show_Left_Point (const uint8_t x, const uint8_t y);
    void Show_Right_Point (const uint8_t x, const uint8_t y);
    void Print (const uint8_t x, const uint8_t y, uint8_t data, bool AInvert);
    void PrintString (const uint8_t x, const uint8_t y, const char *S, bool AInvert);
    void Clear_Uint (const uint8_t x, const uint8_t y);
    void PrintUint(const uint8_t x, const uint8_t y, uint16_t ANumber, bool AInvert);
    void PrintUint0_360(const uint8_t x, const uint8_t y, uint16_t ANumber, bool AInvert);
    void PrintUint0_60(const uint8_t x, const uint8_t y, uint16_t ANumber, bool AInvert);
    void PrintInt(const uint8_t x, const uint8_t y, int16_t ANumber, bool AInvert);
    void PrintUint0_99(const uint8_t x, const uint8_t y, uint8_t ANumber, bool AInvert);
    void print_alpha(const uint8_t x, const uint8_t y);
    void print_betta(const uint8_t x, const uint8_t y);
    void print_angle(const uint8_t x, const uint8_t y);
    void print_minute(const uint8_t x, const uint8_t y);
};

extern lcd_t LCD;
#endif /* LCD_INIT_H_ */
